package com.quzitech.efest.view;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.quzitech.efest.R;
import com.quzitech.efest.handle.IDiaolgHandler;

public class MyDialog {
	Context context;
	IDiaolgHandler handler;
	Dialog dialog;
	TextView ok, no;
	TextView tv_first, tv_secord, tv_third;
	ImageView iv_dialog_icon;

	/**
	 * init the dialog
	 * 
	 * @return
	 */
	public MyDialog(Context con) {
		this.context = con;
		dialog = new Dialog(context, R.style.dialog);
		dialog.setCanceledOnTouchOutside(false);
		dialog.setContentView(R.layout.view_dialog);
		iv_dialog_icon = (ImageView) dialog.findViewById(R.id.iv_dialog_icon);

		tv_first = (TextView) dialog.findViewById(R.id.tv_dialog_first);

		ok = (TextView) dialog.findViewById(R.id.bt_dialogok);

		ok.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				handler.dialogYes("");
				dismiss();
			}
		});
		no = (TextView) dialog.findViewById(R.id.bt_dialogno);

		no.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				handler.dialogNo("");
				dismiss();
			}
		});
	}

	public void setLeftText(int resId) {
		this.ok.setText(resId);

	}

	public void setRightText(int resId) {
		this.no.setText(resId);

	}

	public void setImageIcon(int resId) {
		this.iv_dialog_icon.setImageResource(resId);
		this.iv_dialog_icon.setVisibility(View.VISIBLE);
	}

	public void setFirstText(String str) {
		this.tv_first.setText(str);
	}

	public void setFirstText(int str) {
		this.tv_first.setText(str);
	}

	public void setDialogHandler(IDiaolgHandler handler) {
		this.handler = handler;
	}

	public void show() {
		dialog.show();
	}

	public void hide() {
		dialog.hide();
	}

	public void dismiss() {
		dialog.dismiss();
	}
}